package buffer;

import java.util.List;
import java.util.Vector;

/**
 * The {@link BufferCollection} class allows putting the same value in multiple {@link Drain}s.
 */
public class BufferCollection<T> {
	
	private final List<Buffer<T>> buffers;
	
	private List<Buffer<T>> getBuffers() {
		return buffers;
	}
	/**
	 * Constructor of {@link BufferCollection}.
	 */
	public BufferCollection(){
		buffers = new Vector<Buffer<T>>();		
	}
	
	/**
	 * Adds a constant {@link Buffer} to this {@link BufferCollection}.
	 * The added {@link Buffer} recieves each value that is put via the put method on this object.
	 * @param buffer is a {@link Buffer} that will recieve 
	 */
	public void add(final Buffer<T> buffer){
		this.buffers.add(buffer);
	}
	
	/**
	 * Puts the provided value in each {@link Buffer} that was put in this {@link BufferCollection}.
	 * @param value is the value that is put in each {@link Buffer} in this {@link BufferCollection}.
	 */
	public void put(final T value){
		for(final Buffer<T> buffer : this.getBuffers()){
			buffer.put(value);
		}
	}
}
